import React, { Component } from 'react'
import { withRouter } from 'react-router';
import './Header.css'

class Header extends Component {
  render() {
    return (
      <div className="Header">
        <button onClick={() => this.navigator('back')}>后退</button>
        <button onClick={() => this.navigator('go')}>刷新</button>
        <button onClick={() => this.navigator('forward')}>前进</button>
      </div>
    )
  }

  navigator = (type) => {
    switch (type) {
      case 'back':
        this.props.history.goBack()
        break;
      case 'go':
        this.props.history.go()
        break;
      case 'forward':
        this.props.history.goForward()
        break;
      default:
        console.warn('传入参数未匹配到任何规定值')
        break;
    }
  }
}

export default withRouter(Header)
